# # 提取salary列的前5行
# import pandas as pd
# df1 = pd.DataFrame([['Snow'],['Tyrion'],['Sansa'],['Arya']], columns=['asin'])
# print("--------更换单个值----------")
# new = pd.DataFrame({'asin': 'popopo'}, index=[1])
# print(new)
# df1=df1.append(new, ignore_index=True)  # ignore_index=True,表示不按原来的索引，从0开始自动递增
# print(df1)
# df1.to_csv('Result1.csv',index=None)


# import pandas as pd
# df1 = pd.DataFrame([['Snow'],['Tyrion'],['Sansa'],['Arya']], columns=['asin'])
# df1.to_csv('Result1.csv',index=None)
#
#
# df2 = pd.DataFrame([['999999']], columns=['asin'])
# df2.to_csv('Result1.csv',index=None,mode='a')
#
# df3 = DataFrame(np.arange(16).reshape((4, 4)), index=['a', 'b', 'c', 'd'], columns=['one', 'two', 'three', 'four'])
#
# df3.loc['new'] = ['a']
# # 新插入的行一定要加 index,不然会报错
#
# df3.to_csv('Result8.csv', index=None)

from pandas import DataFrame


class saveCSV(object):
    def __init__(self, index):
        self.index = index
        # self.df = []
    def createCVS(self):
        self.df = DataFrame([], index=['0'], columns=['asin'])
        self.index = self.index + 1
    def locLine(self, info):
        self.df.loc[self.index] = info

    def toCVS(self):
        self.df.to_csv('japan.csv', index=None)
